package cn.itsource.ymcc.controller;

import cn.itsource.ymcc.dto.SmsCodeDto;
import cn.itsource.ymcc.result.JsonResult;
import cn.itsource.ymcc.service.VerifycodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
public class CommonController {

    @Autowired
    private VerifycodeService verifycodeService;

    @GetMapping("/imageCode/{imageCodeKey}")
    public JsonResult imageCode(@PathVariable("imageCodeKey")String imageCodeKey){
       return verifycodeService.imageCode(imageCodeKey);
    }

    @PostMapping("/sendSmsCode")
    public JsonResult sendSmsCode(@Validated @RequestBody SmsCodeDto smsCodeDto){
        return verifycodeService.sendSmsCode(smsCodeDto);
    }
}
